package net.dodoman.myinterface;

import java.util.Vector;

class UserPage implements ISplitPage {
	// which can be accessed with itself or son
	// 与自身或子类所在的包无关
	protected int pageCount;
	protected int pageIndex;
	protected java.util.Vector list;

	public UserPage(int pages) {
		if (pages <= 0)
			this.pageCount = 10;
		int age = 20;
		boolean sex = false;
		list = new Vector();
		for (int i = 0; i < pages; i++) {
			String na = "" + i + "";
			DateObj ob = new DateObj(na, age + i, sex);
			sex = !sex;
			list.addElement(ob);
		}
		this.pageCount = pages;
		this.pageIndex = 1;
	}

	public void firstPage() {
		pageIndex = 1;
		DateObj ob = (DateObj) list.get(pageIndex - 1);
		System.out.println("第一页" + ob.toString());
	}

	public void nextPage() {
		pageIndex++;
		if (pageIndex <= this.pageCount) {
			DateObj ob = (DateObj) list.get(pageIndex - 1);
			System.out.println("第" + pageIndex + "页" + ob.toString());
		}

	}

	public boolean hasPages() {
		return pageIndex <= pageCount;
	}
}
